require("babel-polyfill");
//const assert = require("assert");
const chai = require("chai");
const expect = chai.expect;
const should = chai.should();
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);

import GunDb from "../src/gun";

let gun;
beforeEach(function() {
  gun = new GunDb();
});

describe("Gun", function() {
  describe("put", function() {
    it("should return value by key", function() {
      const res = gun.put("key", { foo: "bar" });
      res.should.eventually.have.property("foo");
      return res.should.be.fulfilled;
    });
  });

  describe("get", function() {
    beforeEach(async function() {
      await gun.put("key", { foo: "bar" });
    });

    it("should return value by key", function() {
      const res = gun.get("key");
      res.should.eventually.have.property("foo");
      return res.should.be.fulfilled;
    });
  });
});
